Option Explicit On
Option Strict On


Public Class cRandomGenerator


    Private Shared pRandom As Random


    Private Shared Sub Initialize()
        If pRandom Is Nothing Then
            pRandom = New Random()
        End If
    End Sub


    Friend Shared Function NextRandom(ByVal MinimumValueToReturn As Integer, ByVal MaximumValueToReturn As Integer) As Integer

        Dim RandomInteger As Integer

        cRandomGenerator.Initialize()

        RandomInteger = pRandom.Next(MinimumValueToReturn, MaximumValueToReturn + 1)
        ' random next maxvalue is exclusive, that's the reason for +1

        Return RandomInteger

    End Function

    Friend Shared Function NextRandomBetweenZeroAndOne() As Double

        Dim RandomDouble As Double

        cRandomGenerator.Initialize()

        RandomDouble = pRandom.NextDouble()

        Return RandomDouble

    End Function


End Class
